log using S11_S18_farmer_sample.smcl,replace
use  NER_panel_data.dta, clear
gen country=1
append using NIGERIA_panel_data.dta
replace country=2 if country ==.

append using ETHIOPIA_panel_data.dta
replace country=3 if country ==.

append using UGA_panel_data.dta
replace country=4 if country ==.

append using TZA_panel_data.dta
replace country=5 if country ==.

append using MWI_panel_data.dta
replace country=6 if country ==.

xtset HHID_panel year

label define country 1 "Niger" 2 "Nigeria" 3 "Ethiopia" 4 "Uganda" 5 "Tanzania" 6 "Malawi"
label values country country
drop if non_farmer==1

foreach x of varlist hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop hdd9 pdd9 no_species{
egen `x'_mean=mean(`x'), by(HHID_panel)
}
tab year, generate(year_)
global year_NIGER year_4
global year_NIGERIA year_3 year_5 year_8
global year_ETHIOPIA year_6
global year_UGANDA   year_3 year_4 year_6 year_8 year_10
global year_TANZANIA year_1 year_5 year_7
global year_MALAWI year_3 year_6 
global xlist hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop  motobike_mean phone_mean electricity_mean wagejob_mean enterprise_mean  




********************************************************************************
*                                   S11                                        *
********************************************************************************
eststo clear
xtreg hdd9  no_species   $xlist  no_species_mean i.country i.year  , cluster(HHID_panel) 
eststo est1


xtreg hdd9  no_species   $xlist  no_species_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  no_species   $xlist  no_species_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3


xtreg hdd9  no_species   $xlist  no_species_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  no_species   $xlist  no_species_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  no_species   $xlist  no_species_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6

xtreg hdd9  no_species   $xlist  no_species_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7

esttab using  S11_farmer.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(no_species   $xlist  no_species_mean _cons)




********************************************************************************
*                                   S12                                        *
********************************************************************************
eststo clear

xtreg hdd9  pdd9   $xlist   pdd9_mean i.country i.year, cluster(HHID_panel) 
eststo est1


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6

xtreg hdd9  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S12_farmer.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons)








********************************************************************************  
*                                 S13_S14                                      *
******************************************************************************** 
preserve
eststo clear
drop if hdd9_own==.|hdd9_purchase==.
drop  pdd9_mean no_species_mean hhsize_mean dependent_share_mean head_age_mean female_head_mean head_read_mean motobike_mean phone_mean electricity_mean wagejob_mean enterprise_mean weather_shock_mean plot_area_mean other_crop_mean
foreach x of varlist pdd9 hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop{
egen `x'_mean=mean(`x'), by(HHID_panel)
}

eststo clear
xtreg hdd9_own  pdd9   $xlist  pdd9_mean i.country i.year  , cluster(HHID_panel) 
eststo est1


xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9_own  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S13_farmer.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons)



eststo clear
xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean i.country i.year  , cluster(HHID_panel) 
eststo est1


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7

esttab using  S14_farmer.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons)
restore





********************************************************************************
*                                  S15_S18                                     *
********************************************************************************
preserve
drop if sum_vill<=1|sum_vill==.

drop pdd9_mean no_species_mean hhsize_mean dependent_share_mean head_age_mean female_head_mean head_read_mean motobike_mean phone_mean electricity_mean wagejob_mean enterprise_mean weather_shock_mean plot_area_mean other_crop_mean
egen pdd9_mean=mean(pdd9), by(HHID_panel)
egen pdd9_mean_vill=mean(pdd9_vill), by(HHID_panel)
egen pdd9_mean_town=mean(pdd9_town), by(HHID_panel)
egen pdd9_mean_dist=mean(pdd9_dist), by(HHID_panel)

foreach x of varlist hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop{
egen `x'_mean=mean(`x'), by(HHID_panel)
}


*                                  hh_level                                    *
eststo clear
xtreg hdd9  pdd9   $xlist  pdd9_mean i.country i.year  , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7


esttab using  S15_farmer.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons )





*                          vill_village_level                                  *

eststo clear
xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill i.country i.year   , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_MALAWI  if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S16_farmer.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9_vill    $xlist  pdd9_mean_vill sum_vill _cons)






*                          town_village_level                                  *
eststo clear
xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town i.country i.year   , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_MALAWI  if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9 pdd9_town sum_town  $xlist  pdd9_mean_town $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S17_farmer.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9_town    $xlist  pdd9_mean_town sum_town _cons)




*                          dist_village_level                                  *

eststo clear
xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist i.country i.year   , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_MALAWI  if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9 pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S18_farmer.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9_dist    $xlist  pdd9_mean_dist sum_dist _cons)
restore



























********************************************************************************
*                Farmer sample with Heckman selection correction               *
********************************************************************************
use  NER_panel_data.dta, clear
gen country=1
append using NIGERIA_panel_data.dta
replace country=2 if country ==.

append using ETHIOPIA_panel_data.dta
replace country=3 if country ==.

append using UGA_panel_data.dta
replace country=4 if country ==.

append using TZA_panel_data.dta
replace country=5 if country ==.

append using MWI_panel_data.dta
replace country=6 if country ==.

xtset HHID_panel year

label define country 1 "Niger" 2 "Nigeria" 3 "Ethiopia" 4 "Uganda" 5 "Tanzania" 6 "Malawi"
label values country country



egen mean_non_farmer=mean(non_farmer), by(country year)
gen farmer_sample=non_farmer==0


probit farmer_sample dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  mean_non_farmer i.country i.year
predict xb, xb
gen double imr = normalden(xb)/normal(xb)
drop if non_farmer==1

foreach x of varlist hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop hdd9 pdd9 no_species{
egen `x'_mean=mean(`x'), by(HHID_panel)
}

tab year, generate(year_)
global year_NIGER year_4
global year_NIGERIA year_3 year_5 year_8
global year_ETHIOPIA year_6
global year_UGANDA   year_3 year_4 year_6 year_8 year_10
global year_TANZANIA year_1 year_5 year_7
global year_MALAWI year_3 year_6 
global xlist hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop  motobike_mean phone_mean electricity_mean wagejob_mean enterprise_mean  imr






********************************************************************************
*                                   S11                                        *
********************************************************************************
eststo clear
xtreg hdd9  no_species   $xlist  no_species_mean i.country i.year  , cluster(HHID_panel) 
eststo est1


xtreg hdd9  no_species   $xlist  no_species_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  no_species   $xlist  no_species_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3


xtreg hdd9  no_species   $xlist  no_species_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  no_species   $xlist  no_species_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  no_species   $xlist  no_species_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6

xtreg hdd9  no_species   $xlist  no_species_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7

esttab using  S11_farmer_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(no_species   $xlist  no_species_mean _cons)




********************************************************************************
*                                   S12                                        *
********************************************************************************
eststo clear

xtreg hdd9  pdd9   $xlist   pdd9_mean i.country i.year, cluster(HHID_panel) 
eststo est1


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6

xtreg hdd9  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S12_farmer_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons)








********************************************************************************  
*                                 S13_S14                                      *
******************************************************************************** 
preserve
eststo clear
drop if hdd9_own==.|hdd9_purchase==.
drop  pdd9_mean no_species_mean hhsize_mean dependent_share_mean head_age_mean female_head_mean head_read_mean motobike_mean phone_mean electricity_mean wagejob_mean enterprise_mean weather_shock_mean plot_area_mean other_crop_mean
foreach x of varlist pdd9 hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop{
egen `x'_mean=mean(`x'), by(HHID_panel)
}

eststo clear
xtreg hdd9_own  pdd9   $xlist  pdd9_mean i.country i.year  , cluster(HHID_panel) 
eststo est1


xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9_own  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9_own  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S13_farmer_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons)



eststo clear
xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean i.country i.year  , cluster(HHID_panel) 
eststo est1


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9_purchase  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7

esttab using  S14_farmer_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons)
restore





********************************************************************************
*                                  S15_S18                                     *
********************************************************************************
preserve
drop if sum_vill<=1|sum_vill==.

drop pdd9_mean no_species_mean hhsize_mean dependent_share_mean head_age_mean female_head_mean head_read_mean motobike_mean phone_mean electricity_mean wagejob_mean enterprise_mean weather_shock_mean plot_area_mean other_crop_mean
egen pdd9_mean=mean(pdd9), by(HHID_panel)
egen pdd9_mean_vill=mean(pdd9_vill), by(HHID_panel)
egen pdd9_mean_town=mean(pdd9_town), by(HHID_panel)
egen pdd9_mean_dist=mean(pdd9_dist), by(HHID_panel)

foreach x of varlist hhsize dependent_share head_age female_head head_read  motobike phone  electricity wagejob enterprise weather_shock  plot_area other_crop{
egen `x'_mean=mean(`x'), by(HHID_panel)
}


*                                  hh_level                                    *
eststo clear
xtreg hdd9  pdd9   $xlist  pdd9_mean i.country i.year  , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9   $xlist  pdd9_mean $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9   $xlist  pdd9_mean $year_MALAWI if country==6, cluster(HHID_panel) 
eststo est3


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9   $xlist  pdd9_mean $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9   $xlist  pdd9_mean  $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7


esttab using  S15_farmer_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9   $xlist  pdd9_mean _cons )





*                          vill_village_level                                  *

eststo clear
xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill i.country i.year   , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_MALAWI  if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9_vill sum_vill  $xlist  pdd9_mean_vill $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S16_farmer_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9_vill    $xlist  pdd9_mean_vill sum_vill _cons)






*                          town_village_level                                  *
eststo clear
xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town i.country i.year   , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_MALAWI  if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9 pdd9_town sum_town  $xlist  pdd9_mean_town $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9_town sum_town  $xlist  pdd9_mean_town $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S17_farmer_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9_town    $xlist  pdd9_mean_town sum_town _cons)




*                          dist_village_level                                  *

eststo clear
xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist i.country i.year   , cluster(HHID_panel) 
eststo est1

xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_ETHIOPIA if country==3, cluster(HHID_panel) 
eststo est2

xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_MALAWI  if country==6, cluster(HHID_panel) 
eststo est3

xtreg hdd9 pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_NIGER if country==1, cluster(HHID_panel) 
eststo est4


xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_NIGERIA if country==2, cluster(HHID_panel) 
eststo est5


xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_TANZANIA if country==5, cluster(HHID_panel) 
eststo est6


xtreg hdd9  pdd9_dist  sum_dist  $xlist pdd9_mean_dist $year_UGANDA if country==4, cluster(HHID_panel) 
eststo est7
esttab using  S18_farmer_imr.rtf, se replace star(* 0.1 ** 0.05 *** 0.01) cells (b(star fmt(%9.3f)) se (par(( )) fmt(%9.3f)))  stats(N r2_b  r2_w r2_o p, fmt(%4.0f %4.3f %4.3f %6.3f)) keep(pdd9_dist    $xlist  pdd9_mean_dist sum_dist _cons)
restore
log close

